import request from "@/requst";

type TUserParams = {
    loginname: string;
    password: string;
};

interface IUserRegister {
    tel: string;
    password: string;
}

export const userLogin = (params: TUserParams) => {
    return request.post("http://121.89.205.189:3000/api/user/login", params);
};

export const msgCode = (params: { tel: string }) => {
    return request.post("http://121.89.205.189:3000/api/user/dosendmsgcode", params);
};

export const userRegister = (params: IUserRegister) => {
    return request.post("http://121.89.205.189:3000/api/user/dofinishregister", params);
};

export const getSeckillList = (params: {
    count: number;
    limitNum?: number;
}) => {
    return request.get(
        `http://121.89.205.189:3000/api/pro/seckilllist?count=${params.count}&limitNum=${params.limitNum}`
    );
};

export const getProList = (params: { count: number; limitNum?: number }) => {
    return request.get(
        `http://121.89.205.189:3000/api/pro/list?count=${params.count}&limitNum=${params.limitNum}`
    );
};

export const getProduceDetail = (params: string) => {
    return request.get(`http://121.89.205.189:3000/api/pro/detail/${params}`);
};

export const getCity = (params?: any) => {
    return request.get('/city/sortCity.json', { params })
}

export const getCategorylist = () => {
    return request.get(`http://121.89.205.189:3000/api/pro/categorylist`)
}

export const getCategorybrandlist = (params: { category: string }) => {
    return request.get(`http://121.89.205.189:3000/api/pro/categorybrandlist?category=${params.category}`)
}
export const getSearch = (params: { count: number; limitNum?: number; keyword?: string }) => {
    return request.get(`http://121.89.205.189:3000/api/pro/search?count=${params.count}&limitNum=${params.limitNum}&keyword=${params.keyword}`)
}

export const getHotword = (params?: any) => {
    return request.get('http://121.89.205.189:3000/api/pro/hotword', { params })
}
